package com.qf.lanzhou.blog.api.controller;

import com.qf.lanzhou.blog.api.pojo.entity.Article;
import com.qf.lanzhou.blog.api.service.ArticleDetailService;
import com.qf.lanzhou.blog.api.service.impl.ArticleDetailServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author Nerly
 * @Date 2020/12/19 10:54
 * @JDK 1.8
 * @Version 1.0
 */
@WebServlet("/detail.do")
public class ArticleDetailServlet extends BaseServletPost{
    private ArticleDetailService articleDetailService = new ArticleDetailServiceImpl();
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("doPost");
        Article article = paramsToEntity(req, Article.class);
        Article articleById = articleDetailService.getArticleById(article);
        articleById.setArticleCreatetimeStr(articleById.getArticleCreatetime());
        System.out.println("servlet:"+articleById.toString());
        successResultWrite(articleById,resp);
    }
}
